<script>
    const xhr = new XMLHttpRequest();
    xhr.timeout = 3000;
    xhr.ontimeout = function () {
        alert(1);
    }
    xhr.open('get', 'http://www.liulongbin.top:3006/api/getbooks');
    xhr.send();
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4) {
            console.log(xhr.responseText)
        }
    }
</script>